var DeptAttendanceModel = function (attendance) {
  BaseModel.call(this);
  var self = this;

  var fn = {
    initData: function (attendance) {
      var fields = ['deptName', 'workshopName', 'workshopPresonNum', 'todayOndutyPersonNum', 'latePresonNum', 'lateNum', 'earlyPresonNum',
        'earlyNum', 'fillcardPresonNum', 'fillcardNum', 'leavePresonNum', 'leaveNum', 'absentPresonNum', 'absentNum'
      ];
      self.setDataFromObj(attendance, fields);
    }
  };

  this.getChartSerieData = function () {
    var axisMap = DeptAttendanceModel.axisMap;
    var fields = _.keys(axisMap);
    var data = [];
    for (var i = 0; i < fields.length; i++) {
      var field = fields[i];
      data.push(this[field]);
    }

    var workshopName = this.workshopName;
    var deptWorkshop = [this.deptName];
    if (!SysUtil.isEmpty(workshopName)) {
      deptWorkshop.push(workshopName);
    }
    return {
      data: data,
      name: deptWorkshop.join('-')
    };
  };

  fn.initData(attendance);
};

DeptAttendanceModel.axisMap = {
  workshopPresonNum: '车间人数',
  todayOndutyPersonNum: '今日上班人数',
  latePresonNum: '月迟到人数',
  lateNum: '月迟到次数',
  earlyPresonNum: '月早退人数',
  earlyNum: '月早退次数',
  fillcardPresonNum: '月补卡人数',
  fillcardNum: '月补卡次数',
  leavePresonNum: '月请假人数',
  leaveNum: '月请假次数',
  absentPresonNum: '月旷工人数',
  absentNum: '月旷工次数'
};

DeptAttendanceModel.getAxisData = function () {
  var axisMap = this.axisMap;
  return _.values(axisMap);
};